<cfif (not isdefined("session.qtables") or fileexists( expandpath('../../xml/webservices.xml') )) or isdefined("url.reinit")>
	<cfinclude template="loadwebservices.cfm"/>
</cfif>
<cfif not isdefined("session.qtables")>
	<cfset session.qtables = QueryNew("id,object,pk,dbtype,dsn","varchar,varchar,varchar,varchar,varchar") />	
</cfif>

<style>
	.tableheader
	{
		font-weight:bold;
		text-decoration:underline;
	}
	img{
	border:0px
	}
</style>
<cfoutput>
<h1>Webservices Modeling</h1>
<a href="../../index.cfm"><img src="images/arrow_left.png" /> Back to the Application Root</a><br />
<br />
<fieldset>
	<legend>Info</legend>
	<table>
		<tr>
			<td align="right">
				<strong>Datasource:</strong>
			</td>
			<td>
				#session.dsn#
			</td>
		</tr>
		<tr>
			<td align="right">
				<strong>Application name in Application.cfc:</strong>
			</td>
			<td>
				#session.appname#
			</td>
		</tr>
	</table>
</fieldset>
<br />

<cfset scriptname = replace(getdirectoryfrompath(cgi.SCRIPT_NAME), "/", ".", "ALL") />
<cfset scriptname = mid(scriptname,2, len(scriptname))/>

<fieldset>
	<legend>Webservice Tables <a href="edittable.cfm"><img src="images/add.png" /></a></legend>
		<table>
		<tr>
			<td class="tableheader">Action</td>
			<td class="tableheader">Object</td>
			<td class="tableheader">Primary Key</td>
			<td class="tableheader">Database Type</td>
			<td class="tableheader">Datasource</td>
			<td class="tableheader">Changes Applied Yet?</td>
		</tr>
		<cfloop query="session.qtables">
		<cfset table = createobject("component", "#scriptname#.table").init("#object#", "#pk#", "#dbtype#", session.dsn) />
		<tr>
			<td><a href="" target="_blank"><img src="images/arrow_left.png" /></a> <a href="edittable.cfm?id=#id#"><img src="images/application_edit.png"/></a> <a onclick="if(confirm('Are you sure you want to delete this page?  No code will be affected.'))return true; return false;" href="deletetable.cfm?id=#id#"><img src="images/delete.png"/></a></td>
			<td>#object#</td>
			<td>#pk#</td>
			<td>#dbtype#</td>
			<td>#session.dsn#</td>
			<td><cfif table.changestoapply() neq "">Not applied yet - <a href="applytable.cfm?id=#id#">Click here to apply</a><cfelse>Changes already applied.</cfif></td>
		</tr>
		</cfloop>
	</table>
</fieldset>
</cfoutput>
